//jQ 狗都不用
const Ajax = {
    get: function (url, callback) {
        let http;
        if (window.XMLHttpRequest) {
            http = new XMLHttpRequest();
        } else {
            http = new ActiveXObject("Microsoft.XMLHTTP");
        }

        http.onreadystatechange = function() {
            if(http.readyState ==4 && http.readyState ==200){
                callback(http.responseText);
            }
        }

        http.open("GET", url, true);
        http.send();
    },
    post: function (url, data, callback) {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                callback(xmlhttp.responseText);
            }
        }
        xmlhttp.open("POST", url, true);
        xmlhttp.setRequestHeader("Content-type", "application/json");
        if (data != null) {
            xmlhttp.send(data);
        } else {
            xmlhttp.send();
        }
    },
    post_file: function(url,form_data,callback){
        let http;
        if(window.XMLHttpRequest){
            http=new XMLHttpRequest();
        }else {
            http=new ActiveXObject("Microsoft.XMLHTTP");
        }
        http.onreadystatechange =function () {
            if(http.readyState==4 && http.status ==200){
                callback(http.responseText);
            }
        }
        http.open("POST",url,true);
        http.send(form_data);
    },
    postFile: function (url, data, callback) {
        var xmlhttp;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        } else {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                callback(xmlhttp.responseText);
            }
        }
        xmlhttp.open("POST", url, true);
        if (data != null) {
            xmlhttp.send(data);
        } else {
            xmlhttp.send();
        }
    },
    doMethod: function (url, data, async, callback) {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                callback(xmlhttp.responseText);
            }
        }
        xmlhttp.open("POST", url, async);
        xmlhttp.setRequestHeader("Content-type", "application/json");
        if (data != null) {
            xmlhttp.send(data);
        } else {
            xmlhttp.send();
        }
    }
}

function formJson(formId) {
    var form = document.getElementById(formId);
    var result = "\"" + form.elements[0].name + "\":\"" + form.elements[0].value + "\"";
    for (var i = 1; i < form.length; i++) {
        if (form.elements[i].type == "radio") {
            if (!form.elements[i].checked) {
                continue;
            }
        }
        result = result + ",\"" + form.elements[i].name + "\":\"" + form.elements[i].value + "\""
    }
    return '{' + result + '}';
}

function formatDate(t) {
    // let t = new Date(time);
    var time = t.getFullYear() + "年" +
        (t.getMonth() + 1) + "月" +
        t.getDate() + "日 " +
        t.getHours() + ":" +
        t.getMinutes() + ":" +
        t.getSeconds();
    return time;
}
function scholarship_type(i) {
    switch (i) {
        case 1:return "安徽省政府奖学金";
        case 2:return "黄山学院迎客松国际学生奖学金";
        case 3:return "新生入学奖学金";
        case 4:return "学业奖学金";
        case 5:return "丝绸之路奖学金";
    }
}
function del(json){
    for(let value in json){
        if(json[value].check==true){
            json.splice(value,1);
            del(json);
        }
    }
}